package org.FaPe3D.engine.elements
{
	import org.FaPe3D.Adapter;
	import org.FaPe3D.engine.modifiers.*;
	import org.FaPe3D.utils.InitialValues;
	import org.papervision3d.core.proto.MaterialObject3D;
	import org.papervision3d.objects.primitives.Cylinder;
	import org.papervision3d.view.layer.util.ViewportLayerSortMode;

	public class FPCylinder extends Cylinder
	{
		private var _width:Number;
		private var _height:Number;
		private var _depth:Number;
		private var _bend:FPBend;
		private var _index:int;
		
		public function FPCylinder(material:MaterialObject3D=null, radius:Number=100, height:Number=100, segmentsW:int=8, segmentsH:int=8, topRadius:Number=100, topFace:Boolean=true, bottomFace:Boolean=true, initObject:Object=null)
		{
			_width = InitialValues.MinWidth;
			_height = InitialValues.MinHeight;
			_depth = InitialValues.MinDepth;
			super(material, radius, height, segmentsW, segmentsH, topRadius, topFace, bottomFace, initObject);
		}
		
		public function get index():int
		{
			return _index;
		}
		
		public function set index(num:int):void
		{
			Adapter.getCurrentAdapter().viewports.getDefaultViewport().containerSprite.sortMode = ViewportLayerSortMode.INDEX_SORT;
			_index = num;
			Adapter.getCurrentAdapter().viewports.getDefaultViewport().getChildLayer(this, true).layerIndex = _index;
		}
		
		public function get quickBend():Object
		{
			return new Object();
		}
		
		public function set quickBend(params:Object):void
		{
			_bend = new FPBend(this);
			_bend.quickBend(params.force,params.offset);
		}
		
		public function get width():Number
		{
			return _width;
		}
		
		public function set width(num:Number):void
		{
			this.scaleX = num /_width;
			_width = num;
		}
		
		public function get height():Number
		{
			return _height;
		}
		
		public function set height(num:Number):void
		{
			this.scaleY = num /_height;
			_height = num;
		}
		
		public function get depth():Number
		{
			return _depth;
		}
		
		public function set depth(num:Number):void
		{
			this.scaleZ = num /_depth;
			_depth = num;
		}
		
	}
}